package cfdt.tools.util;

/**
 * <pre>
 * Modify Information:
 * Author       Date        Description
 * ============ =========== ============================
 * zhangxing    2009-05-04  Create this file
 * clsu         2011-04-20  add function
 * LiangPanpan  2015-09-25  增加向左向右补字符的方法
 * </pre>
 */
public class StringUtils {

    public static final String DEFAULT_CHARSET = "UTF-8";

    /**
     * 判断字符串是否为空
     *
     * @param str
     * @return
     */
    public static boolean isEmpty(String str) {
        if (null == str || "".equals(str.trim())) {
            return true;
        } else {
            return false;
        }
    }

    /**
     * 判断字符串是否不为空
     */
    public static boolean isNotEmpty(String str) {
        if (str != null && !"".equals(str.trim())) {
            return true;
        } else {
            return false;
        }
    }

    public static String replace(String string, String replacement) {
        if (string != null) {
            return string.replaceAll(replacement, "");
        } else {
            return null;
        }
    }

    /**
     *
     */
    public static String trim(String string) {
        if (isEmpty(string)) {
            return "";
        } else {
            return string.trim();
        }
    }

}
